using System;
using System.Collections.Generic;
using System.Text;

namespace LiveStock
{
    class HTMLTableCreator
    {

        List<string> table = new List<string>();
        public HTMLTableCreator()
        {
            table.Add("<HTML><HEAD><style>" + LiveStock.Properties.Resources.RssCss + "</style></HEAD><BODY><table>");
        }

        public void addRow(string title, string data)
        {
            string temp = "<tr><th>" + title + ": </th><td>" + data + "</td></tr>";
            table.Add(temp);
        }
        public void addBlankRow()
        {
            string temp = "<tr><td> \n </td></tr>";
            table.Add(temp);
        }
        public void addHorizontalLine()
        {
            string temp = "<tr><th><hr></th><td><hr></td></tr>";
            table.Add(temp);
        }

        public string htmlLink(string htmlTarget, string linkName)
        {
            if (!linkName.Equals(""))
            {
                return ("<a href=" + htmlTarget + ">" + linkName + "</href>");
            }
            else
                return ("<a href=" + htmlTarget + ">" + htmlTarget + "</href>");
        }

        public string createHTMLString()
        {
            StringBuilder sb = new StringBuilder();

           
            if (table.Count != 1)
            {
                foreach (string s in table)
                {
                    sb.Append(s);
                }
                
                sb.Append("</table></BODY>");
            }

            return sb.ToString();
        }

    }
}
